package com.isunland.managesystem.ui;

import com.google.gson.Gson;
import com.isunland.managesystem.base.BaseNetworkDialogFragment;
import com.isunland.managesystem.common.ApiConst;
import com.isunland.managesystem.entity.CustomerDialog;
import com.isunland.managesystem.entity.CustomerMainOriginal;
import com.isunland.managesystem.entity.CustomerMainOriginal.rCustomerMain;
import java.util.ArrayList;
import java.util.List;

public class CustomerNameDialogFragment extends BaseNetworkDialogFragment {

  @Override public ArrayList<CustomerDialog> resolveResponse(String arg0) {
    ArrayList<CustomerDialog> list = new ArrayList<CustomerDialog>();

    CustomerMainOriginal contractContentOriginal =
        new Gson().fromJson(arg0, CustomerMainOriginal.class);

    List<rCustomerMain> dataList = contractContentOriginal.getRows();

    if (dataList == null || dataList.size() == 0) {

      return null;
    }
    for (int i = 0; i < dataList.size(); i++) {
      list.add(new CustomerDialog(dataList.get(i).getCustomerName(), dataList.get(i).getId()));
    }
    return list;
  }

  @Override public String getUrl() {
    return ApiConst.URL_CUSTOMER_LIST;
  }
  //	@Override
  //	public HashMap<String, String> getparameters() {
  //		// Auto-generated method stub
  //		return super.getparameters();
  //	}
}
